home *** CD-ROM | disk | FTP | other *** search
/ PC Open 100 / PC Open 100 CD 1.bin / CD1 / INTERNET / EMAIL / pop file / setup.exe / Platform / MSWin32.pm
Encoding:
Perl POD Document  |  2003-09-19  |  6.7 KB  |  174 lines

  1. # POPFILE LOADABLE MODULE
  2. package Platform::MSWin32;
  3.  
  4. use POPFile::Module;
  5. @ISA = ("POPFile::Module");
  6.  
  7. #----------------------------------------------------------------------------
  8. #
  9. # This module handles POPFile specifics on Windows
  10. #
  11. # Copyright (c) 2001-2003 John Graham-Cumming
  12. #
  13. #   This file is part of POPFile
  14. #
  15. #   POPFile is free software; you can redistribute it and/or modify
  16. #   it under the terms of the GNU General Public License as published by
  17. #   the Free Software Foundation; either version 2 of the License, or
  18. #   (at your option) any later version.
  19. #
  20. #   POPFile is distributed in the hope that it will be useful,
  21. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. #   GNU General Public License for more details.
  24. #
  25. #   You should have received a copy of the GNU General Public License
  26. #   along with POPFile; if not, write to the Free Software
  27. #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. #
  29. #----------------------------------------------------------------------------
  30.  
  31. use strict;
  32. use warnings;
  33. use locale;
  34.  
  35. #----------------------------------------------------------------------------
  36. # new
  37. #
  38. #   Class new() function
  39. #----------------------------------------------------------------------------
  40. sub new
  41. {
  42.     my $type = shift;
  43.     my $class = ref($type) || $type;
  44.     my $self = POPFile::Module->new();
  45.  
  46.     bless $self, $type;
  47.  
  48.     $self->name( 'windows' );
  49.  
  50.     return $self;
  51. }
  52.  
  53. # ---------------------------------------------------------------------------------------------
  54. #
  55. # initialize
  56. #
  57. # Called when we are are being set up but before starting
  58. #
  59. # ---------------------------------------------------------------------------------------------
  60. sub initialize
  61. {
  62.     my ( $self ) = @_;
  63.  
  64.     $self->config_( 'trayicon', 1 );
  65.     $self->config_( 'console',  0 );
  66.  
  67.     $self->register_configuration_item_( 'configuration',
  68.                                          'windows_trayicon',
  69.                                          $self );
  70.  
  71.     $self->register_configuration_item_( 'configuration',
  72.                                          'windows_console',
  73.                                          $self );
  74.  
  75.     return 1;
  76. }
  77.  
  78. # ---------------------------------------------------------------------------------------------
  79. #
  80. # configure_item
  81. #
  82. #    $name            The name of the item being configured, was passed in by the call
  83. #                     to register_configuration_item
  84. #    $language        Reference to the hash holding the current language
  85. #    $session_key     The current session key
  86. #
  87. #  Must return the HTML for this item
  88. # ---------------------------------------------------------------------------------------------
  89.  
  90. sub configure_item
  91. {
  92.     my ( $self, $name, $language, $session_key ) = @_;
  93.  
  94.     my $body;
  95.  
  96.     # Tray icon widget
  97.     if ( $name eq 'windows_trayicon' ) {
  98.         $body .= "<span class=\"configurationLabel\">$$language{Windows_TrayIcon}:</span><br />\n";
  99.         $body .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\"><tr><td nowrap=\"nowrap\">\n";
  100.  
  101.         if ( $self->config_( 'trayicon' ) == 0 ) {
  102.             $body .= "<form action=\"/configuration\">\n";
  103.             $body .= "<span class=\"securityWidgetStateOff\">$$language{No}</span>\n";
  104.             $body .= "<input type=\"submit\" class=\"toggleOn\" id=\"windowTrayIconOn\" name=\"toggle\" value=\"$$language{ChangeToYes}\" />\n";
  105.             $body .= "<input type=\"hidden\" name=\"windows_trayicon\" value=\"1\" />\n";
  106.             $body .= "<input type=\"hidden\" name=\"session\" value=\"$session_key\" />\n</form>\n";
  107.         } else {
  108.             $body .= "<form action=\"/configuration\">\n";
  109.             $body .= "<span class=\"securityWidgetStateOn\">$$language{Yes}</span>\n";
  110.             $body .= "<input type=\"submit\" class=\"toggleOn\" id=\"windowTrayIconOff\" name=\"toggle\" value=\"$$language{ChangeToNo}\" />\n";
  111.             $body .= "<input type=\"hidden\" name=\"windows_trayicon\" value=\"0\" />\n";
  112.             $body .= "<input type=\"hidden\" name=\"session\" value=\"$session_key\" />\n</form>\n";
  113.         }
  114.         $body .= "</td></tr></table>\n";
  115.     }
  116.  
  117.     if ( $name eq 'windows_console' ) {
  118.         $body .= "<span class=\"configurationLabel\">$$language{Windows_Console}:</span><br />\n";
  119.         $body .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\"><tr><td nowrap=\"nowrap\">\n";
  120.  
  121.         if ( $self->config_( 'console' ) == 0 ) {
  122.             $body .= "<form action=\"/configuration\">\n";
  123.             $body .= "<span class=\"securityWidgetStateOff\">$$language{No}</span>\n";
  124.             $body .= "<input type=\"submit\" class=\"toggleOn\" id=\"windowConsoleOn\" name=\"toggle\" value=\"$$language{ChangeToYes}\" />\n";
  125.             $body .= "<input type=\"hidden\" name=\"windows_console\" value=\"1\" />\n";
  126.             $body .= "<input type=\"hidden\" name=\"session\" value=\"$session_key\" />\n</form>\n";
  127.         } else {
  128.             $body .= "<form action=\"/configuration\">\n";
  129.             $body .= "<span class=\"securityWidgetStateOn\">$$language{Yes}</span>\n";
  130.             $body .= "<input type=\"submit\" class=\"toggleOn\" id=\"windowConsoleOff\" name=\"toggle\" value=\"$$language{ChangeToNo}\" />\n";
  131.             $body .= "<input type=\"hidden\" name=\"windows_console\" value=\"0\" />\n";
  132.             $body .= "<input type=\"hidden\" name=\"session\" value=\"$session_key\" />\n</form>\n";
  133.         }
  134.         $body .= "</td></tr></table>\n";
  135.     }
  136.  
  137.     return $body;
  138. }
  139.  
  140. # ---------------------------------------------------------------------------------------------
  141. #
  142. # validate_item
  143. #
  144. #    $name            The name of the item being configured, was passed in by the call
  145. #                     to register_configuration_item
  146. #    $language        Reference to the hash holding the current language
  147. #    $form            Hash containing all form items
  148. #
  149. #  Must return the HTML for this item
  150. # ---------------------------------------------------------------------------------------------
  151.  
  152. sub validate_item
  153. {
  154.     my ( $self, $name, $language, $form ) = @_;
  155.  
  156.     if ( $name eq 'windows_trayicon' ) {
  157.         if ( defined($$form{windows_trayicon}) ) {
  158.             $self->config_( 'trayicon', $$form{windows_trayicon} );
  159.             return $$language{Windows_NextTime};
  160.         }
  161.     }
  162.  
  163.     if ( $name eq 'windows_console' ) {
  164.         if ( defined($$form{windows_console}) ) {
  165.             $self->config_( 'console', $$form{windows_console} );
  166.             return $$language{Windows_NextTime};
  167.         }
  168.     }
  169.  
  170.    return '';
  171. }
  172.  
  173. 1;
  174.